package com.adong.config;

import com.adong.pojo.Happiness;
import org.junit.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * @author adong
 * @Profile : 指定组件在那个环境的情况下才能注册到容器中,不指定任何环境下都能注册这个组件
 * 加了环境标识的bean,只有激活这个环境被激活才能注册到容器中,默认@Profile("default")
 */
@Profile("test")
@Configuration
public class ProfileConfig {
    @Profile("test")
    @Bean
    public Happiness testHappiness() {
        return new Happiness();
    }

    @Profile("dev")
    @Bean
    public Happiness devHappiness() {
        return new Happiness();
    }

    @Profile("prod")
    @Bean
    public Happiness prodHappiness() {
        return new Happiness();
    }
}
